
PROGRAM dataminer

  USE definitions
  USE ast
  USE init
  USE inout
  USE functions

  IMPLICIT NONE
  INTEGER :: i, j, k, l, m
  CHARACTER(len = 8) :: c1, c2
  CHARACTER(len = 40) :: cmd1, cmd2, str
  INTEGER, DIMENSION(2) :: pos
  REAL    :: minhight=0, maxhight=0, maxshadow=0, minshadow=0

  CALL load_parameters
  CALL init_rand(seed)

  m = 0
!  sourceflow = 0.2
!  DO i=1,8
 !    sourceflow = sourceflow + 0.2
  !   L0 = 2
   !  DO l=1,3
        WRITE(*,*) sourceflow, L0, par1, par2
   !     L0 = L0 + 2
        m = m + 1
        CALL init_grid
        
        CALL SYSTEM_CLOCK(count1, countrate, countmax)
        cmd1 = ''
        cmd2 = ''
        c1 = ''
        c2 = ''
        WRITE(*,*) 'done'
        WRITE(c1, '(E8.2)') L0
        WRITE(c2, '(E8.2)') sourceflow
        WRITE(*,*) 'c'
        str = 'L0' // c1 // 'S' // c2
        cmd1 = 'mkdir ' // str
        WRITE(*,*) 'calling system with', cmd1
        CALL SYSTEM(cmd1)
        WRITE(*,*) 'calling ast_main with sourceflow = ', sourceflow
        CALL ast_main
        cmd2 = 'mv data/* ' // str
        WRITE(*,*) 'calling system with', cmd2
        CALL SYSTEM(cmd2)
        
 !ENDDO
 !ENDDO

END PROGRAM dataminer
